/*
 *      net_view.h
 *      
 *      Copyright 2009 AzureSky <AzureSky.fedora@gmail.com>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

#ifndef _NET_VIEW_H_
#define _NET_VIEW_H_

#include <glibmm.h>
#include <gtkmm.h>
//#include <libglademm.h>
#include <sstream>
#include <string>
#include <cstdio>
#include "../lib/net_list.h"

class net_view : public Gtk::TreeView
{
	public:
		net_view(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& refGlade);
		~net_view();
		const Glib::RefPtr<Gtk::Builder>& refXml;
		void net_refresh();
	private:
		void init_view();
		void net_title();
		void net_read();
		void add_row(std::list<net_link>::iterator);
		class net_tree : public Gtk::TreeModel::ColumnRecord
  		{
  			public:
				net_tree(){ 
					add (m_proto); 
					add (m_local);
					add (m_local_port);
					add (m_foreign);
					add (m_remote_port);
					add (m_stat);
				}

    				Gtk::TreeModelColumn<std::string> m_proto;
    				Gtk::TreeModelColumn<std::string> m_local;
    				Gtk::TreeModelColumn<unsigned int> m_local_port;
    				Gtk::TreeModelColumn<std::string> m_foreign;
    				Gtk::TreeModelColumn<unsigned int> m_remote_port;
    				Gtk::TreeModelColumn<std::string> m_stat;
  		};
		net_tree net_list;
		Glib::RefPtr<Gtk::ListStore> p_net_model;

		class net_list the_list;
};
#endif //_NET_VIEW_H_
